package com.wxl.www.wxl.shiro.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wxl.www.wxl.shiro.entity.SysRole;
import com.wxl.www.wxl.shiro.entity.UserInfo;
import com.wxl.www.wxl.shiro.mapper.SysPermissionMapper;
import com.wxl.www.wxl.shiro.mapper.SysRoleMapper;
import com.wxl.www.wxl.shiro.service.SysRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper,SysRole> implements SysRoleService {

    @Resource
    private SysRoleMapper sysRoleMapper;
    /**
     * 获取权限
     */
    @Resource
    private SysPermissionMapper sysPermissionMapper;

    @Override
    public SysRole findByUserInfo(UserInfo user) {
        SysRole byUserInfo = sysRoleMapper.findByUserName(user.getUserName());
        byUserInfo.setPermissions(sysPermissionMapper.findBySysRole(byUserInfo.getId()));
        return byUserInfo;
    }
}
